package edu.ynu.se.xiecheng.achitectureclass.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.Set;

@Entity
@Getter
@Setter
@Where(clause = "is_deleted = 0")
public class OrderItem extends LogicEntity{
    @Column
    private int quanity;

    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnoreProperties("orderItems")
    private Commodity commodity;

    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnoreProperties("orderItems")
    private Order order;

    public double getItemCost(){return quanity*commodity.getPrice();}



}
